/**
 * Project: apollo-base-tools
 * 
 * File Created at 2017年8月1日
 * 
 * Copyright 2015-2016 dx.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DongXue software Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with dx.com.
 */
package org.apollo.base.tools.ui.view;

import java.awt.BorderLayout;
import java.awt.Component;

import javax.swing.Icon;
import javax.swing.JPanel;

/** 
* @ClassName: JAccordionPanel 
* @Description: 手风琴折叠面板
* @author wuzhenfang(wzfbj2008@163.com)
* @date 2017年8月1日 下午4:52:58 
* @version V1.0 
*/
public class JAccordionPanel extends JPanel {

	private static final long serialVersionUID = 2649405591837312170L;

	private JLayerPane layerPane;// 层面板

	public JAccordionPanel() {
		super();
	}

	public JAccordionPanel(String title, Icon icon, Component comp) {
		this();
		getLayerPane().addPane(title, icon, comp);
	}

	/**
	 * 添加折叠项
	 * @param title
	 * @param icon
	 * @param comp
	 */
	public void addItemPanel(String title, Icon icon, Component comp) {
		getLayerPane().addPane(title, icon, comp);
	}

	public void setAnimated(boolean flag) {
		getLayerPane().setAnimated(flag);
		add(getLayerPane(), BorderLayout.CENTER);
	}

	/**
	 * 层面板
	 * @return the layerPane
	 */
	public JLayerPane getLayerPane() {
		if (layerPane == null) {
			layerPane = new JLayerPane();
			layerPane.setAnimated(true);
			layerPane.setSelectedPane(0);//show the first layer.
		}
		return layerPane;
	}

}
